package cn.cdutetc.library.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户角色枚举
 */
@Getter
@AllArgsConstructor
public enum UserRoleEnum {
    // 对齐数据库/开发文档的取值
    ADMIN("system_admin", "管理员"),
    LIBRARIAN("book_admin", "图书管理员"),
    READER("normal_user", "读者");
    
    private final String code;
    private final String desc;
    
    public static UserRoleEnum getByCode(String code) {
        for (UserRoleEnum role : values()) {
            if (role.getCode().equals(code)) {
                return role;
            }
        }
        return null;
    }
}